package com.suian.spring.config;

import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;

@Configuration
public class TestRedisConfig {
    @Bean
    public CommandLineRunner checkRedisConfig(RedisConnectionFactory factory) {
        return args -> {
            if (factory instanceof LettuceConnectionFactory) {
                LettuceConnectionFactory lettuceFactory = (LettuceConnectionFactory) factory;
                System.out.println("=== Redis 配置调试信息 ===");
                System.out.println("Host: " + lettuceFactory.getHostName());
                System.out.println("Port: " + lettuceFactory.getPort());
                System.out.println("Password: " + lettuceFactory.getPassword());
                System.out.println("Database: " + lettuceFactory.getDatabase());
                System.out.println("==========================");
            } else {
                System.out.println("Redis 连接工厂不是 Lettuce 类型，实际类型: " + factory.getClass().getName());
            }
        };
    }
}
